﻿

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新增订单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" >
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" >
    
    <style>
        .layui-form-label.required:after { 
            content: '*';
            color: red;
        }
        .layui-table td, .layui-table th {
            position: relative;
            padding: 5px 5px;
            min-height: 20px;
            line-height: 20px;
            font-size: 14px
        }
        .layui-table img {
            max-width: 150px
        }
    </style>
</head>
<body>
    <input type="hidden" id="ysdxx" />
    <div class="layui-fluid" id="component-tabs">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-lg2">
                <button class="layui-btn" id="ysd">点击选择预收单</button>
            </div>
            <div class="layui-col-lg1">

            </div>
            <div class="layui-col-lg2">
                <label class="layui-form-label" id="lbl_ysdhh">预收单号：</label><label class="layui-form-label" id="lbl_ysdh"></label>
            </div>
            <div class="layui-col-lg2 layui-col-lg-offset5" id="tjandbc">
                <button class="layui-btn" lay-submit onclick="submit('tj')" id="submit" lay-filter="component-form-element">立即提交</button>
                <button class="layui-btn" lay-save onclick="submit('save')" id="save" lay-filter="component-form-element">保存</button>
            </div>
        </div>
        <div class="layui-card" id="allcontent">
            <div class="layui-card-body">
                <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
                    <ul class="layui-tab-title">
                        <li class="layui-this" lay-id="1">基本信息</li>
                        <li lay-id="2">款式设计</li>
                        <li lay-id="3">尺寸信息</li>
                        <li lay-id="4">预览界面</li>
                    </ul>
                    <div class="layui-tab-content">
                        <!--基本信息-->
                        <div class="layui-tab-item layui-show">
                            <!--基本信息start-->
                            <div class="layui-card-body">
                                <table class="layui-table">
                                    <tbody>
                                        <tr>
                                            <td width="130px">
                                                <label class="layui-form-label">店仓名称：</label>
                                            </td>
                                            <td width="250px">
                                                <input type="text" readonly="readonly" name="fullname" id="txt_mendian" class="layui-input">
                                            </td>
                                            <td width="120px"><input type="hidden" id="hid_storeid" /><label class="layui-form-label">店仓代码：</label></td>
                                            <td width="150px"> <input type="text" readonly="readonly" name="fullname" id="txt_storecode" class="layui-input"></td>
                                            <td width="120px">
                                                <label class="layui-form-label required">顾客姓名：</label>
                                            </td>
                                            <td width="200px">
                                                <input type="text" name="fullname" id="txt_gkxm" lay-verify="required" placeholder="请填写顾客姓名" autocomplete="off" class="layui-input">
                                            </td>
                                            <td width="120px">
                                                <label class="layui-form-label">联系方式：</label>
                                            </td>
                                            <td width="180px">
                                                <input type="text" name="fullname" id="txt_lxfs" lay-verify="required" placeholder="请填写手机号" autocomplete="off" class="layui-input">
                                            </td>
                                            <td width="120px">
                                                <label class="layui-form-label">身高：</label>
                                            </td>
                                            <td width="180px">
                                                <input type="text" name="fullname" onblur="check_two(this)" on id="txt_shengao" lay-verify="required" placeholder="请填写身高 厘米（cm）" autocomplete="off" class="layui-input">
                                            </td>
                                            <td width="120px">
                                                <label class="layui-form-label">体重：</label>
                                            </td>
                                            <td width="180px">
                                                <input type="text" name="fullname" onblur="check_two(this)" id="txt_tizhong" lay-verify="required" placeholder="请填写身高 千克（kg）" autocomplete="off" class="layui-input">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="120px">
                                                <label class="layui-form-label">是否直发：</label>
                                            </td>
                                            <td width="180px">
                                                <div class="layui-card layui-form">
                                                    <input type="checkbox" name="zzz" id="ck_iszf" lay-filter="switchTest" lay-skin="switch" lay-text="是|否">
                                                </div>
                                            </td>
                                            <td width="120px">
                                                <label class="layui-form-label">邮寄地址：</label>
                                                <input type="hidden" id="hid_address">
                                            </td>
                                            <td colspan="9">
                                                <input type="text" name="fullname" id="txt_address" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="120px">
                                                <label class="layui-form-label">是否加急：</label>
                                            </td>
                                            <td width="180px">
                                                <div class="layui-card layui-form">
                                                    <input type="checkbox" name="ck_isjj" id="ck_isjj" lay-filter="switch_jj" lay-skin="switch" lay-text="是|否">
                                                </div>
                                            </td>
                                            <td width="120px">
                                                <label class="layui-form-label">加急天数：</label>
                                            </td>
                                            <td colspan="1">
                                                <input type="text" name="fullname" id="txt_jjts" readonly="readonly" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                                            </td>
                                            <td width="120px">
                                                <label class="layui-form-label">加急费用：</label>
                                            </td>
                                            <td colspan="1">
                                                <input type="text" name="fullname" id="txt_jjfy" readonly="readonly" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <!--基本信息end-->
                            <!--服装信息start-->
                            <form class="layui-form" action="" lay-filter="component-form-group">
                                <div class="layui-card-body">
                                    <table class="layui-table">
                                        <colgroup>
                                            <col width="100">
                                            <col width="100">
                                            <col width="60">
                                            <col width="80">
                                            <col width="80">
                                            <col width="100">
                                            <col width="100">
                                            <col width="100">
                                            <col width="100">
                                            <col width="100">
                                            <col width="100">
                                            <col width="100">
                                        </colgroup>
                                        <thead>
                                            <tr>
                                                <th>款号</th>
                                                <th>品名</th>
                                                <th>长短袖</th>
                                                <th>尺码</th>
                                                <th>价格</th>
                                                <th>需求数量</th>
                                                <th>面料品牌</th>
                                                <th>面料编码</th>
                                                <th>工厂面料号</th>
                                                <th>用料米数</th>
                                                <th>订货日期</th>
                                                <th>交货日期</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td><span id="kh"></span></td>
                                                <td><span id="pm"></span></td>
                                                <td>
                                                    <div class="layui-card layui-form">
                                                        <input type="checkbox" name="ck_iscd" id="ck_iscd" lay-filter="switch_cd" lay-skin="switch" lay-text="长袖|短袖">
                                                    </div>
                                                </td>
                                                <td>
                                                    <select name="sel_cm" id="sel_cm" class="layui-form-select" lay-filter="sel_cm"></select>
                                                </td>
                                                <td><span id="jg"></span></td>
                                                <td>
                                                    <input type="text" id="txt_sl" onchange="check_cc(this)" onblur="check_zzs(this)" name="fullname" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                                                    <input type="hidden" id="hid_sl" />
                                                    <input type="hidden" id="hid_xiaolei" />
                                                </td>

                                                <td><span id="mlpp"></span></td>
                                                <td><span id="mlbm"></span></td>
                                                <td><input type="text" id="txt_gcmlh" name="fullname" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"></td>
                                                <td><input type="text" id="txt_ylms" onblur="check_two(this)" name="fullname" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"></td>
                                                <td><input type="text" class="layui-input" id="dhrq" placeholder="yyyy-MM-dd"></td>
                                                <td><input type="text" id="jhrq" name="jhrq" lay-verify="required" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input"></td>
                                            </tr>

                                        </tbody>
                                    </table>
                                </div>
                            </form>
                            <!--服装信息end-->
                            <div class="layui-card-body" style="text-align:right">
                                <button class="layui-btn site-demo-active" data-type="tabChange_kssj">进入款式设计</button>
                            </div>
                        </div>
                        <!--款式设计-->
                        <div class="layui-tab-item">
                            <!--选择图片信息start-->
                            <div class="layui-card-body">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                    </colgroup>
                                    <thead>
                                        <tr>
                                            <th>后背</th>
                                            <th>领型</th>
                                            <th>袖口</th>
                                            <th>前门襟</th>
                                            <th>下摆</th>
                                            <th>口袋</th>
                                            <th>领插片</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        <tr>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('hb')" id="hbpic" src="../../layuiadmin/style/res/template/hb_icon.png">
                                            </td>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('lx')" id="lxpic" src="../../layuiadmin/style/res/template/lx_icon.png">
                                            </td>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('xk')" id="xkpic" src="../../layuiadmin/style/res/template/xk_icon.png">
                                            </td>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('qmj')" id="qmjpic" src="../../layuiadmin/style/res/template/qmj_icon.png">
                                            </td>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('xb')" id="xbpic" src="../../layuiadmin/style/res/template/xb_icon.png">
                                            </td>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('kd')" id="kdpic" src="../../layuiadmin/style/res/template/kd_icon.png">
                                            </td>
                                            <td>
                                                <img width="150" height="150" onclick="select_pic('lcp')" id="lcppic" src="../../layuiadmin/style/res/template/lcp_icon.png">
                                            </td>

                                        </tr>
                                        <tr>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="hbbh"></p>
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="lxbh"></p>
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="xkbh"></p>
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="qmjbh"></p>
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="xbbh"></p>
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="kdbh"></p>
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="lcpbh"></p>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="hbmc"></p>
                                                <input id="hbid" type="hidden" value="">
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="lxmc"></p>
                                                <input id="lxid" type="hidden" value="">
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="xkmc"></p>
                                                <input id="xkid" type="hidden" value="">
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="qmjmc"></p>
                                                <input id="qmjid" type="hidden" value="">
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="xbmc"></p>
                                                <input id="xbid" type="hidden" value="">
                                            </td>

                                            <td>
                                                <p class="layadmin-homepage-min-font" id="kdmc"></p>
                                                <input id="kdid" type="hidden" value="">
                                            </td>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="lcpmc"></p>
                                                <input id="lcpid" type="hidden" value="">
                                            </td>

                                        </tr>
                                    </tbody>
                                    <thead>
                                        <tr>
                                            <th>绣花部位</th>
                                            <th id="th_xhzt">绣花字体</th>
                                            <th id="th_xhys">绣花颜色</th>
                                            <th id="th_xhbz">绣花备注</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>

                                            <td>
                                                <img width="150" height="150" onclick="select_pic('xhbw')" id="xhbwpic" src="../../layuiadmin/style/res/template/xhbw_icon.png">
                                            </td>
                                            <td id="td_pic_xhzt">
                                                <img width="150" height="150" onclick="select_pic('xhzt')" id="xhztpic" src="../../layuiadmin/style/res/template/xhzt_icon.png">
                                            </td>
                                            <td id="td_pic_xhys">
                                                <img width="150" height="150" onclick="select_pic('xhys')" id="xhyspic" src="../../layuiadmin/style/res/template/xhys_icon.png">
                                            </td>
                                            <td rowspan="3" id="td_pic_xhbz">
                                                <textarea name="txt_xh_remark" rows="8" id="txt_xh_remark" placeholder="其他要求" class="layui-textarea"></textarea>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <p class="layadmin-homepage-min-font" id="xhbwbh"></p>
                                            </td>
                                            <td id="td_bh_xhzt">
                                                <p class="layadmin-homepage-min-font" id="xhztbh"></p>
                                            </td>
                                            <td id="td_bh_xhys">
                                                <p class="layadmin-homepage-min-font" id="xhysbh"></p>
                                            </td>
                                        </tr>
                                        <tr>

                                            <td>
                                                <p class="layadmin-homepage-min-font" id="xhbwmc"></p>
                                                <input id="xhbwid" type="hidden" value="">
                                            </td>
                                            <td id="td_mc_xhzt">
                                                <p class="layadmin-homepage-min-font" id="xhztmc"></p>
                                                <input id="xhztid" type="hidden" value="">
                                            </td>
                                            <td id="td_mc_xhys">
                                                <p class="layadmin-homepage-min-font" id="xhysmc"></p>
                                                <input id="xhysid" type="hidden" value="">
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <!--选择图片信息end-->
                            <div class="layui-card-body" style="text-align:right">
                                <button class="layui-btn site-demo-active" data-type="tabChange_ccxx">进入尺寸信息</button>
                            </div>
                        </div>
                        <!--尺寸信息-->
                        <div class="layui-tab-item">
                            <!--尺寸信息start-->
                            <div class="layui-card-body layui-col-lg3" id="cmtable">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                        <col width="150">
                                    </colgroup>
                                    <thead>
                                        <tr>
                                            <th>部位</th>
                                            <th>参考规格</th>
                                            <th>规格修正</th>
                                            <th>成衣尺寸</th>
                                        </tr>
                                    </thead>
                                    <tbody id="list_cm"></tbody>
                                </table>
                            </div>
                            <!--尺寸信息end-->
                            <!--其他尺寸信息start-->
                            <div class="layui-card-body layui-col-lg2" id="ttcmtable">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="150">
                                        <col width="150">
                                    </colgroup>
                                    <thead>
                                        <tr>
                                            <th>特体修改</th>
                                            <th>修改值</th>
                                        </tr>
                                    </thead>
                                    <tbody id="list_othercm"></tbody>
                                </table>
                            </div>
                            <!--其他尺寸信息end-->
                            <!--装饰工艺start-->
                            <div class="layui-card-body layui-col-lg2" id="gytable">
                                <form class="layui-form" action="" lay-filter="component-form-group">
                                    <table class="layui-table">
                                        <colgroup>
                                            <col width="150">
                                            <col width="150">
                                        </colgroup>
                                        <thead>
                                            <tr>
                                                <th>工艺名称</th>
                                                <th>选择项</th>
                                            </tr>
                                        </thead>
                                        <tbody id="list_othergy">
                                            <tr>
                                                <td>纽扣</td>
                                                <td>  <select name="sel_nkgy" id="sel_nkgy" class="layui-form-select" lay-filter="sel_nkgy"></select></td>
                                            </tr>
                                            <tr>
                                                <td>门襟装饰线</td>
                                                <td>  <select name="sel_mjgy" id="sel_mjgy" class="layui-form-select" lay-filter="sel_mjgy"></select></td>
                                            </tr>
                                            <tr>
                                                <td>领子装饰线</td>
                                                <td>  <select name="sel_lzgy" id="sel_lzgy" class="layui-form-select" lay-filter="sel_lzgy"></select></td>
                                            </tr>
                                            <tr>
                                                <td>袖口装饰线</td>
                                                <td>  <select name="sel_xkgy" id="sel_xkgy" class="layui-form-select" lay-filter="sel_xkgy"></select></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </form>
                            </div>
                            <!--装饰工艺end-->
                            <!--备注信息start-->
                            <div class="layui-card-body layui-col-lg5">
                                <table class="layui-table">
                                    <thead>
                                        <tr>
                                            <th>特体处理（请标明修改部位）    此处可填写说明</th>
                                        </tr>
                                    </thead>
                                    <tr>
                                        <td>
                                            <textarea name="other" rows="8" id="txt_other_remark" placeholder="填写说明" class="layui-textarea"></textarea>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div class="layui-upload">
                                                <button type="button" class="layui-btn" id="test-upload-more">特殊说明图片上传</button>
                                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                                    <div class="layui-upload-list" id="test-upload-more-list"></div>
                                                    <input id="pic_url" type='hidden'>
                                                </blockquote>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <!--备注信息end-->
                            <div class="layui-card-body layui-col-lg12" style="text-align:right">
                                <button class="layui-btn site-demo-active" data-type="tabChange_yljm">进入预览界面</button>
                            </div>
                        </div>
                        <!--预览-->
                        <div class="layui-tab-item">
                            <button type="button" class="layui-btn" onclick="exportTable()">导出EXCEL</button>
                            <table id="tableExcel"  style="width:900px;" border="1" cellspacing="0" cellpadding="0">
                                <!--<table class="layui-table" id="tableExcel" width="70%" border="1" cellspacing="0" cellpadding="0" >-->
                                <colgroup>
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                    <col width="150">
                                </colgroup>
                                <thead>
                                    <tr>
                                        <th colspan="8" style="text-align:center;">沙驰衬衫私人定制单</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td colspan="8" style="text-align:right;">订单编号：<label id="lbl_ddbh"></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">门店名称：<label id="lbl_storename"></label></td>
                                        <td colspan="3">门店代码：<label id="lbl_storecode"></label></td>
                                        <td colspan="2">下单人：<label id="lbl_xdr"></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">顾客姓名：<label id="lbl_gkname"></label></td>
                                        <td colspan="2">身高：<label id="lbl_gksg"></label></td>
                                        <td colspan="2">体重：<label id="lbl_gktz"></label></td>
                                        <td colspan="2">下单时间：<label id="lbl_xdsj"></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="6">发货地址：<label id="lbl_address"></label>

                                        </td>
                                        <td colspan="2">需求交期：<label id="lbl_xqjq"></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">面料品牌：<label id="lbl_mlpp"></label></td>
                                        <td colspan="4">工厂面料号：<label id="lbl_gcmlh"></label></td>
                                        <td colspan="2">是否直寄顾客：<label id="lbl_sfzfgk"></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" contenteditable="true">面料标：<label id="lbl_mlb"></label></td>
                                        <td colspan="2" contenteditable="true">商标位置：<label id="lbl_sbwz"></label></td>
                                        <td colspan="2" contenteditable="true">洗标位置：<label id="lbl_xbwz"></label></td>
                                        <td colspan="2">产品货号：<label id="lbl_cphh"></label></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">面料需求数量：<label id="lbl_mlxqsl"></label></td>
                                        <td colspan="2">本单下单数量：<label id="lbl_bdxdsl"></label></td>
                                        <td colspan="2">试衣尺码：<label id="lbl_sycm"></label></td>
                                        <td colspan="2">产品名称：<label id="lbl_cpmc"></label></td>
                                    </tr>
                                </tbody>
                                <thead>
                                    <tr>
                                        <th colspan="4" style="text-align:center">尺寸记录</th>
                                        <th colspan="2" style="text-align:center">体型特征</th>
                                        <th colspan="2" style="text-align:center">款式</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>部位</td>
                                        <td>净体尺寸</td>
                                        <td>加放尺寸</td>
                                        <td>成衣尺寸</td>
                                        <td>调整部位</td>
                                        <td>调整值</td>
                                        <td>部位</td>
                                        <td>名称</td>
                                    </tr>
                                </tbody>
                                <tbody id="tb_cm"></tbody>
                                <tbody>
                                    <tr>
                                        <td colspan="8">
                                            备注：<label id="txt_yl_remark"></label>
                                            <!--<textarea name="other" rows="8" id="txt_yl_remark" placeholder="填写说明" class="layui-textarea"></textarea>-->
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="8">
                                            <div class="layui-upload-list" id="test-upload-more-list_yl"></div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="../../layuiadmin/js/jquery.min2.1.4.js"></script>
        <script src="../../layuiadmin/layui/layui.js"></script>
        <script src="../../layuiadmin/js/cookie.js"></script>
        <script src="../../layuiadmin/js/jshelp.js"></script>
        <!--<script src="../../layuiadmin/js/table2excel_bak.js"></script>-->
        <script src="../../layuiadmin/js/table2excel.js"></script>
        <script>
            var clickCount = 0;
            var issave = 0;
            var djbhs = "";

            function base64(content) {
                return window.btoa(unescape(encodeURIComponent(content)));
            }
            function tableToExcel(tableID, fileName) {
                var excelContent = $("#" + tableID).html();
                var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
                excelFile += "<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head>";
                excelFile += "<body><table width='10%'  border='1'>";
                excelFile += excelContent;
                excelFile += "</table></body>";
                excelFile += "</html>";
                var link = "data:application/vnd.ms-excel;base64," + base64(excelFile);
                var a = document.createElement("a");
                a.download = fileName + ".xls";
                a.href = link;
                a.click();
            }

            //导出excel
            //var table2excel = new Table2Excel();
            function exportTable() {
                var date = new Date();
                var month = date.getMonth() + 1;
                var nowtime = date.getFullYear()+"年" + month+"月" + date.getDate() +"日"+ date.getHours()+"时" + date.getMinutes()+"分" + date.getSeconds()+"秒";
                tableToExcel("tableExcel", "高定下单" + nowtime);
                //table2excel.export(document.getElementById('tableExcel'));
                //$("#tableExcel").table2excel({
                //    exclude: ".layui-table", //过滤位置的 css 类名
                //    filename: "衬衫高定.xlsx", //文件名称
                //    name: "Excel Document Name.xlsx",
                //    exclude_img: false,//是否导出图片 false导出
                //    exclude_links: true,//是否导出链接 false导出
                //    exclude_inputs: true//是否导出输入框的值 true导出
                //});

            }
            //#region 验证
            ///超出原数量提示
            function check_cc(gvalue) {
                var yvalue = $('#hid_sl').val();
                if (parseInt(gvalue.value) > parseInt(yvalue)) {
                    layer.msg("您输入的数量超出原数量，请注意！！！", { icon: 5, anim: 6 });
                };
            }
            //验证尺码规格修正输入信息，只能数字并且一位小数
            function check_cm_szAndone(bwid) {
                var txt_ggxz_value = parseFloat($("#txt_ggxz_" + bwid + "").val());//成衣尺寸
                var filter = /^([\+ \-]?(([1-9]\d*)|(0)))([.]\d{0,1})?$/;
                if (filter.test(txt_ggxz_value)) {
                    var txt_max = parseFloat($("#hid_max_" + bwid + "").val());//最大值
                    var txt_min = parseFloat($("#hid_min_" + bwid + "").val());//最小值
                    if (txt_ggxz_value < txt_min || txt_ggxz_value > txt_max) {
                        layer.msg("不能超出修改范围!", { icon: 5, anim: 6 });
                        $("#txt_ggxz_" + bwid + "").val('');
                        //$("#txt_ly_after_" + bwid + "").val('');
                        return false;
                    }
                    else {
                        $("#txt_ly_after_" + bwid + "").val(parseFloat($("#txt_ly_" + bwid + "").val()) + txt_ggxz_value)
                        return true;
                    }
                }
                else {
                    if ($("#txt_ggxz_" + bwid + "").val() != "") {
                        layer.msg("只能输入数字且1位小数", { icon: 5, anim: 6 });
                        $("#txt_ggxz_" + bwid + "").val('');
                        $("#txt_ly_after_" + bwid + "").val(parseFloat($("#txt_ly_" + bwid + "").val()));
                    }
                    else if ($("#txt_ggxz_" + bwid + "").val() == "") {
                        $("#txt_ly_after_" + bwid + "").val(parseFloat($("#txt_ly_" + bwid + "").val()));
                    }
                    //txt.focus();
                    return false;
                }
            }
            //验证自定义参考规格尺码输入信息，只能正数字并且一位小数
            function check_zdycm_ckgg_szAndone(bwid) {
                var txt_ly_value = parseFloat($("#txt_ly_" + bwid + "").val());//参考规格
                var filter = /^(\d+\.\d{1,1}|\d+)$/;
                if (filter.test(txt_ly_value)) {
                    $("#txt_ly_after_" + bwid + "").val(txt_ly_value);
                    return true;
                }
                else {
                    if ($("#txt_ly_" + bwid + "").val() != "") {
                        layer.msg("只能输入数字且1位小数", { icon: 5, anim: 6 });
                        $("#txt_ly_" + bwid + "").val('');
                        $("#txt_ly_after_" + bwid + "").val(txt_ly_value);
                    }
                    else if ($("#txt_ly_" + bwid + "").val() == "") {
                        $("#txt_ly_after_" + bwid + "").val(txt_ly_value);
                    }
                    //txt.focus();
                    return false;
                }
            }
            //验证自定义尺码规格修正输入信息，只能数字并且一位小数
            function check_zdycm_ggxz_szAndone(bwid) {
                var txt_ggxz_value = parseFloat($("#txt_ggxz_" + bwid + "").val());//成衣尺寸
                var filter = /^([\+ \-]?(([1-9]\d*)|(0)))([.]\d{0,1})?$/;
                if (filter.test(txt_ggxz_value)) {
                    $("#txt_ly_after_" + bwid + "").val(parseFloat($("#txt_ly_" + bwid + "").val()) + txt_ggxz_value)
                    return true;
                }
                else {
                    if ($("#txt_ggxz_" + bwid + "").val() != "") {
                        layer.msg("只能输入数字且1位小数", { icon: 5, anim: 6 });
                        $("#txt_ggxz_" + bwid + "").val('');
                        //$("#txt_ly_after_" + bwid + "").val('');
                        $("#txt_ly_after_" + bwid + "").val(parseFloat($("#txt_ly_" + bwid + "").val()));
                    }
                    else if ($("#txt_ggxz_" + bwid + "").val() == "") {
                        $("#txt_ly_after_" + bwid + "").val(parseFloat($("#txt_ly_" + bwid + "").val()));
                    }
                    //txt.focus();
                    return false;
                }
            }
            //验证特体尺码修正输入信息，只能数字并且一位小数
            function check_ttcm_szAndone(bwid) {
                var txt_ttcmxz_value = parseFloat($("#txt_ttcm_" + bwid + "").val());//特体修正尺寸
                var filter = /^([\+ \-]?(([1-9]\d*)|(0)))([.]\d{0,1})?$/;
                if (filter.test(txt_ttcmxz_value)) {
                    var txt_max = parseFloat($("#ttcm_hid_max_" + bwid + "").val());//最大值
                    var txt_min = parseFloat($("#ttcm_hid_min_" + bwid + "").val());//最小值
                    if (txt_ttcmxz_value < txt_min || txt_ttcmxz_value > txt_max) {
                        layer.msg("不能超出修改范围!", { icon: 5, anim: 6 });
                        $("#txt_ttcm_" + bwid + "").val('');
                        return false;
                    }
                    else {
                        return true;
                    }
                }
                else {
                    if ($("#txt_ttcm_" + bwid + "").val() != "") {
                        layer.msg("只能输入数字且1位小数", { icon: 5, anim: 6 });
                        $("#txt_ttcm_" + bwid + "").val('');
                    }
                    //txt.focus();
                    return false;
                }
            }
            //#endregion 验证结束
            //提交
            function submit(status) {
                var lbl_ysdh = $("#lbl_ysdh").text();//预收单号
                var txt_mendian = $("#txt_mendian").val();//门店名称
                var txt_storecode = $("#txt_storecode").val();//门店代码
                var hid_storeid = $("#hid_storeid").val();//门店id
                var txt_gkxm = $("#txt_gkxm").val();//顾客姓名
                var txt_lxfs = $("#txt_lxfs").val();//联系方式
                var txt_shengao = $("#txt_shengao").val();//身高
                var txt_tizhong = $("#txt_tizhong").val();//体重
                var iszf = $("#ck_iszf").prop("checked");//是否直发
                var txt_address = $("#txt_address").val();//地址
                var isjj = $("#ck_isjj").prop("checked");//是否加急
                var iscd = $("#ck_iscd").prop("checked");//长短袖
                var jjts = $("#txt_jjts").val();//加急天数
                var jjfy = $("#txt_jjfy").val();//加急费用
                var kh = $("#kh").text();//款号
                var pm = $("#pm").text();//品名
                var xiaolei = $("#hid_xiaolei").val();//小类
                var sel_cm = $("select[name='sel_cm']").val();//尺码
                var jg = $("#jg").text();//价格
                var txt_sl = $("#txt_sl").val();//数量
                var mlpp = $("#mlpp").text();//面料品牌
                var mlbm = $("#mlbm").text();//面料编码
                var txt_gcmlh = $("#txt_gcmlh").val();//工厂面料号
                var txt_ylms = $("#txt_ylms").val();//用料米数
                var dhrq = $("#dhrq").val();//订货日期
                var jhrq = $("#jhrq").val();//交货日期

                var gy_nkid = $("select[name='sel_nkgy']").val();//纽扣工艺值
                var gy_mjid = $("select[name='sel_mjgy']").val();//门襟工艺值
                var gy_lzid = $("select[name='sel_lzgy']").val();//领子工艺值
                var gy_xkid = $("select[name='sel_xkgy']").val();//袖口工艺值

                var lxid = $('#lxid').val();//领型id
                var lxbh = $('#lxbh').text();//领型编号
                var lxmc = $('#lxmc').text();//领型名称
                var lxpic = $('#lxpic').attr('src');//领型src
                var xkid = $('#xkid').val();//袖口id
                var xkbh = $('#xkbh').text();//袖口编号
                var xkmc = $('#xkmc').text();//袖口名称
                var xkpic = $('#xkpic').attr('src');//袖口src
                var qmjid = $('#qmjid').val();//前门襟id
                var qmjbh = $('#qmjbh').text();//前门襟编号
                var qmjmc = $('#qmjmc').text();//前门襟名称
                var qmjpic = $('#qmjpic').attr('src');//前门襟src
                var xbid = $('#xbid').val();//下摆id
                var xbbh = $('#xbbh').text();//下摆编号
                var xbmc = $('#xbmc').text();//下摆名称
                var xbpic = $('#xbpic').attr('src');//下摆src
                var hbid = $('#hbid').val();//后背id
                var hbbh = $('#hbbh').text();//后背编号
                var hbmc = $('#hbmc').text();//后背名称
                var hbpic = $('#hbpic').attr('src');//后背src
                var kdid = $('#kdid').val();//口袋id
                var kdbh = $('#kdbh').text();//口袋编号
                var kdmc = $('#kdmc').text();//口袋名称
                var kdpic = $('#kdpic').attr('src');//口袋src
                var lcpid = $('#lcpid').val();//领插片id
                var lcpbh = $('#lcpbh').text();//领插片编号
                var lcpmc = $('#lcpmc').text();//领插片名称
                var lcppic = $('#lcppic').attr('src');//领插片src
                var xhbwid = $('#xhbwid').val();//绣花部位id
                var xhbwbh = $('#xhbwbh').text();//绣花部位编号
                var xhbwmc = $('#xhbwmc').text();//绣花部位名称
                var xhbwpic = $('#xhbwpic').attr('src');//绣花部位src
                var xhztid = $('#xhztid').val();//绣花字体id
                var xhztbh = $('#xhztbh').text();//绣花字体编号
                var xhztmc = $('#xhztmc').text();//绣花字体名称
                var xhztpic = $('#xhztpic').attr('src');//绣花字体src
                var xhysid = $('#xhysid').val();//绣花颜色id
                var xhysbh = $('#xhysbh').text();//绣花颜色编号
                var xhysmc = $('#xhysmc').text();//绣花颜色名称
                var xhyspic = $('#xhyspic').attr('src');//绣花颜色src
                var txt_xh_remark = $("#txt_xh_remark").val();//绣花其他要求
                var txt_other_remark = $("#txt_other_remark").val();//备注
                var pic_urls = urls;//备注图片


                if (status == "tj") {
                    if (txt_gkxm == "" || txt_gkxm == null || txt_gkxm == undefined) {
                        layer.msg('顾客姓名不能为空', { icon: 5 });
                        return;
                    }
                    if (txt_address == "" || txt_address == null || txt_address == undefined) {
                        layer.msg('收货地址不能为空', { icon: 5 });
                        return;
                    }
                    if (sel_cm == "" || sel_cm == null || sel_cm == undefined) {
                        layer.msg('尺码不能为空', { icon: 5 });
                        return;
                    }
                    if (txt_sl == "" || txt_sl == null || txt_sl == undefined) {
                        layer.msg('需求数量不能为空', { icon: 5 });
                        return;
                    }
                    if (mlbm == "" || mlbm == null || mlbm == undefined) {
                        layer.msg('面料编码不能为空', { icon: 5 });
                        return;
                    }
                    if (txt_gcmlh == "" || txt_gcmlh == null || txt_gcmlh == undefined) {
                        layer.msg('工厂面料号不能为空', { icon: 5 });
                        return;
                    }
                    //if (txt_ylms == "" || txt_ylms == null || txt_ylms == undefined) {
                    //    layer.msg('用料米数不能为空', { icon: 5 });
                    //    return;
                    //}
                    if (dhrq == "" || dhrq == null || dhrq == undefined) {
                        layer.msg('订货日期不能为空', { icon: 5 });
                        return;
                    }
                    if (jhrq == "" || jhrq == null || jhrq == undefined) {
                        layer.msg('交货日期不能为空', { icon: 5 });
                        return;
                    }
                    if (lxid == "" || lxid == null || lxid == undefined) {
                        layer.msg('领型图片未选择', { icon: 5 });
                        return;
                    }
                    if (xkid == "" || xkid == null || xkid == undefined) {
                        layer.msg('袖口图片未选择', { icon: 5 });
                        return;
                    }
                    if (qmjid == "" || qmjid == null || qmjid == undefined) {
                        layer.msg('前门襟图片未选择', { icon: 5 });
                        return;
                    }
                    if (xbid == "" || xbid == null || xbid == undefined) {
                        layer.msg('下摆图片未选择', { icon: 5 });
                        return;
                    }
                    if (kdid == "" || kdid == null || kdid == undefined) {
                        layer.msg('口袋图片未选择', { icon: 5 });
                        return;
                    }
                    if (lcpid == "" || lcpid == null || lcpid == undefined) {
                        layer.msg('领插片图片未选择', { icon: 5 });
                        return;
                    }
                    if (xhbwid == "" || xhbwid == null || xhbwid == undefined) {
                        //layer.msg('绣花部位图片未选择', { icon: 5 });
                        //return;
                    }
                    else {
                        if (xhztid == "" || xhztid == null || xhztid == undefined) {
                            layer.msg('绣花字体图片未选择', { icon: 5 });
                            return;
                        }
                        if (xhysid == "" || xhysid == null || xhysid == undefined) {
                            layer.msg('绣花颜色图片未选择', { icon: 5 });
                            return;
                        }
                        if (txt_xh_remark == "" || txt_xh_remark == null || txt_xh_remark == undefined) {
                            layer.msg('绣花颜色图片未选择', { icon: 5 });
                            return;
                        }
                    }

                }
                //主体信息
                var arrayObj_main = new Array();
                var main = {
                    "id": $.cookie("id"),
                    "loginid": $.cookie("loginid"),
                    "username": $.cookie("username"),
                    "ysdh": lbl_ysdh,
                    "storeid": hid_storeid,
                    "mendian": txt_mendian,
                    "storecode": txt_storecode,
                    "gkxm": txt_gkxm,
                    "lxfs": txt_lxfs,
                    "shengao": txt_shengao,
                    "tizhong": txt_tizhong,
                    "iszf": iszf,
                    "address": txt_address,
                    "isjj": isjj,
                    "iscd": iscd,
                    "jjts": jjts,
                    "jjfy": jjfy,
                    "kh": kh,
                    "xiaolei": xiaolei,
                    "pm": pm,
                    "cm": sel_cm,
                    "jg": jg,
                    "sl": txt_sl,
                    "mlpp": mlpp,
                    "mlbm": mlbm,
                    "gcmlh": txt_gcmlh,
                    "ylms": txt_ylms,
                    "dhrq": dhrq,
                    "jhrq": jhrq,

                    "gy_nkid": gy_nkid,
                    "gy_mjid": gy_mjid,
                    "gy_lzid": gy_lzid,
                    "gy_xkid": gy_xkid,

                    "lxid": lxid,
                    "lxpic": lxpic,
                    "lxbh": lxbh,
                    "lxmc": lxmc,
                    "xkid": xkid,
                    "xkpic": xkpic,
                    "xkbh": xkbh,
                    "xkmc": xkmc,
                    "qmjid": qmjid,
                    "qmjpic": qmjpic,
                    "qmjbh": qmjbh,
                    "qmjmc": qmjmc,
                    "xbid": xbid,
                    "xbpic": xbpic,
                    "xbbh": xbbh,
                    "xbmc": xbmc,
                    "hbid": hbid,
                    "hbpic": hbpic,
                    "hbbh": hbbh,
                    "hbmc": hbmc,
                    "kdid": kdid,
                    "kdpic": kdpic,
                    "kdbh": kdbh,
                    "kdmc": kdmc,
                    "lcpid": lcpid,
                    "lcppic": lcppic,
                    "lcpbh": lcpbh,
                    "lcpmc": lcpmc,
                    "xhbwid": xhbwid,
                    "xhbwpic": xhbwpic,
                    "xhbwbh": xhbwbh,
                    "xhbwmc": xhbwmc,
                    "xhztid": xhztid,
                    "xhztpic": xhztpic,
                    "xhztbh": xhztbh,
                    "xhztmc": xhztmc,
                    "xhysid": xhysid,
                    "xhyspic": xhyspic,
                    "xhysbh": xhysbh,
                    "xhysmc": xhysmc,

                    "txt_xh_remark": txt_xh_remark,
                    "txt_other_remark": txt_other_remark,
                    "pic_urls": pic_urls
                };
                arrayObj_main.push(main);

                //尺码
                var arrayObj_cm = new Array();
                var mytable_cm = document.getElementById("list_cm");
                var i = mytable_cm.rows.length;
                if (i > 0) {
                    for (var j = 0; j < i; j++) {
                        var hid_id = stringtojson($("#hid_id_" + j).val());
                        var txt_ggxz = stringtojson($("#txt_ggxz_" + j).val());
                        var txt_ly_after = stringtojson($("#txt_ly_after_" + j).val());
                        var ccmc = mytable_cm.rows[j].cells[0].innerText;
                        if (status == "tj") {
                            //如果是自定义填写，袖肥，袖口，后背宽非必填
                            if (sel_cm == "13" && (ccmc == "袖肥" || ccmc == "短袖肥" || ccmc == "长袖衬衫袖口" || ccmc == "短袖口" || ccmc == "后背宽")) {

                            } else {
                                if (txt_ly_after == "" || txt_ly_after == null || txt_ly_after == undefined) {
                                    layer.msg('成衣尺寸信息请填写完整', { icon: 5 });
                                    return;
                                }
                            }

                        }
                        if (hid_id != "") {
                            var cm = {
                                "bwid": hid_id,
                                "ggxz": txt_ggxz,
                                "cmvalue": txt_ly_after
                            };
                            arrayObj_cm.push(cm);
                        }
                    }
                }
                else {
                    if (status == "tj") {
                        layer.msg('成衣尺寸信息未带出，请再次选择尺码后带出成衣尺寸', { icon: 5 });
                        return;
                    }
                }
                //特体尺码
                var arrayObj_ttcm = new Array();
                var mytable_ttcm = document.getElementById("list_othercm");
                var t = mytable_ttcm.rows.length;
                if (t > 0) {
                    for (var j = 0; j < t; j++) {
                        var hid_ttid_id = stringtojson($("#hid_ttid_" + j).val());
                        var txt_ttcm = stringtojson($("#txt_ttcm_" + j).val());
                        if (status == "tj") {
                            //if (txt_ttcm == "" || txt_ttcm == null || txt_ttcm == undefined) {
                            //    layer.msg('特体修改值信息请填写完整', { icon: 5 });
                            //    return;
                            //}
                        }
                        if (hid_ttid_id != "") {
                            var ttcm = {
                                "id": hid_ttid_id,
                                "ttcmvalue": txt_ttcm
                            };
                            arrayObj_ttcm.push(ttcm);
                        }
                    }
                }
                //防止多次点击

                if (clickCount >= 2) {
                    return false;
                }
                else {
                    $.ajax({
                        type: "post",
                        async: true,
                        url: 'ashx/list.ashx?type=order_save&zt=' + status + '&issave=' + issave + '&djbhs=' + djbhs,
                        data: JSON.stringify({ 'ArrayObj_main': arrayObj_main, 'ArrayObj_cm': arrayObj_cm, 'ArrayObj_ttcm': arrayObj_ttcm }),
                        dataType: "json",
                        success: function (res) {
                            var index = parent.layer.getFrameIndex(window.name);
                            if (res.flag == "True") {
                                if (status == "tj") {
                                    djbhs = res.djbh;
                                    clickCount++;
                                    layer.msg(res.remsg, {
                                        time: 2000,
                                        end: function () {
                                            parent.layer.close(index);
                                            window.parent.location.reload();
                                        }
                                    })
                                }
                                else if (status == "save") {
                                    issave = issave + 1;
                                    djbhs = res.djbh;
                                    layer.msg(res.remsg, {
                                        time: 2000,
                                        end: function () {
                                            //parent.layer.close(index);
                                            //window.parent.location.reload();
                                        }
                                    })
                                }
                            }
                            else {
                                layer.alert(res.remsg);
                            }
                        }
                    })
                }
            }
            var urls = '';
            layui.config({
                base: '../../../layuiadmin/' //静态资源所在路径
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index', 'laydate', 'upload', 'form', 'layer'], function () {
                var $ = layui.jquery
                    , laydate = layui.laydate
                    , upload = layui.upload
                    , form = layui.form
                    , layer = layui.layer
                    , element = layui.element
                    , router = layui.router();


                /* 触发事件 */
                var active = {
                    tabChange_kssj: function () {
                        /* 切换到指定Tab项 */
                        element.tabChange('component-tabs-brief', '2');
                    },
                    tabChange_ccxx: function () {
                        /* 切换到指定Tab项 */
                        element.tabChange('component-tabs-brief', '3');
                    },
                    tabChange_yljm: function () {
                        /* 切换到指定Tab项 */
                        element.tabChange('component-tabs-brief', '4');
                    }
                };
                //验证用户是否登录
                if ($.cookie("loginid") == "" || $.cookie("loginid") == null || $.cookie("loginid") == "null" || $.cookie("loginid") == undefined || $.cookie("loginid") == "undefined") {
                    $.removeCookie("id", { path: "/", sucue: true });//用户id
                    $.removeCookie("loginid", { path: "/", sucue: true });//登录账号
                    $.removeCookie("username", { path: "/", sucue: true });//用户名
                    $.removeCookie("role", { path: "/", sucue: true });//权限
                    $.removeCookie("islookme", { path: "/", sucue: true });//权限
                    window.location.href = "../views/user/login.html";
                }
                //加载加急
                var jjts_ts = "";
                var jjfy_fy = "";
                var shrq_add_ts = "";
                $.ajax({
                    type: "get",
                    async: false,
                    url: "ashx/list.ashx?type=getorder_set",
                    dataType: "json",
                    success: function (data) {
                        if (data.data.length > 0) {
                            jjts_ts = data.data[0].jjts;
                            jjfy_fy = data.data[0].jjfy;
                            shrq_add_ts = data.data[0].shrq_add;
                        }

                    },
                    error: function (data) {
                        //layer.error(data);
                    }
                });
                //加载日期控件
                //当前时间
                function getNowtDay(d) {
                    d = new Date(d);
                    return new Date(d).format("yyyy-MM-dd")   //格式为"2019-02-16 00:00:00"
                };
                //当前加天数
                function getAddDay(d, t) {
                    d = new Date(d);
                    d = +d + (1000 * 60 * 60 * 24) * t;
                    d = new Date(d);
                    return new Date(d).format("yyyy-MM-dd")   //格式为"2019-02-16 00:00:00"
                };
                //当前减天数
                function getCutDay(d, t) {
                    d = new Date(d);
                    d = + d - (1000 * 60 * 60 * 24) * t;
                    d = new Date(d);
                    return new Date(d).format("yyyy-MM-dd")   //格式为"2019-02-16 00:00:00"
                };
                var date = new Date();
                var dt = getNowtDay(date);
                var jhrq = getAddDay(date, shrq_add_ts);
                var jhrq_cut = getCutDay(jhrq, jjts_ts);
                laydate.render({
                    elem: '#dhrq'
                    , value: dt
                });
                laydate.render({
                    elem: '#jhrq'
                    , value: jhrq
                });
                //点击tab事件
                element.on('tab(component-tabs-brief)', function (obj) {
                    if (obj.index == 3) {
                        $("#lbl_ddbh").text($("#lbl_ysdh").text());//单号
                        $("#lbl_storename").text($("#txt_mendian").val());//门店名称
                        $("#lbl_storecode").text($("#txt_storecode").val());//门店代码
                        $("#lbl_storecode").text($("#txt_storecode").val());//门店代码
                        $("#lbl_xdr").text($.cookie("username"));//下单人
                        $("#lbl_gkname").text($("#txt_gkxm").val());//顾客姓名
                        $("#lbl_gksg").text($("#txt_shengao").val());//身高
                        $("#lbl_gktz").text($("#txt_tizhong").val());//体重
                        $("#lbl_xdsj").text($("#dhrq").val());//下单时间
                        $("#lbl_address").text($("#txt_address").val());//发货地址
                        $("#lbl_xqjq").text($("#jhrq").val());//需求交期
                        $("#lbl_mlpp").text($("#mlpp").text());//面料品牌
                        $("#lbl_gcmlh").text($("#txt_gcmlh").val());//工厂面料号

                        if ($("#ck_iszf").prop("checked") == true) {
                            $("#lbl_sfzfgk").text("是");//是否直发客户
                        } else {
                            $("#lbl_sfzfgk").text("否");//是否直发客户
                        }
                        $("#lbl_mlb").text("");//面料标
                        $("#lbl_sbwz").text("");//商标位置
                        $("#lbl_xbwz").text("");//洗标位置
                        $("#lbl_cphh").text($("#kh").text());//产品货号
                        $("#lbl_mlxqsl").text($("#txt_ylms").val());//面料需求数量
                        $("#lbl_bdxdsl").text($("#txt_sl").val());//本单下单数量
                        $("#lbl_sycm").text($("#sel_cm option:selected").text());//试衣尺码
                        $("#lbl_cpmc").text($("#pm").text());//产品名称
                        $("#txt_yl_remark").text($("#txt_other_remark").val());//备注
                        //$("#test-upload-more-list_yl").html($("#test-upload-more-list").html());//图片
                        //var wburl = "http://yj.satchi.com.cn:8085/Files/2021071510500068_satchi_logo.jpg";
                        //var imgs = '<img src="' + wburl + '"  alt="image" class="layui-upload-img">';
                        //$("#test-upload-more-list_yl").html(imgs);//图片
                        $("#test-upload-more-list_yl").html(imgurl);//图片

                        $("#tb_cm").html("");
                        //尺码
                        var mytable_cm = document.getElementById("list_cm");
                        var c = mytable_cm.rows.length;
                        //特体尺码
                        var mytable_ttcm = document.getElementById("list_othercm");
                        var t = mytable_ttcm.rows.length;
                        var str_tr = "";
                        for (var i = 0; i < 16; i++) {
                            str_tr += "<tr>";
                            if (c > i) {
                                str_tr += "<td> " + mytable_cm.rows[i].cells[0].innerHTML + "</td>";
                                str_tr += "<td> " + $("#txt_ly_" + i + "").val() + "</td>";
                                str_tr += "<td> " + $("#txt_ggxz_" + i + "").val() + "</td>";
                                str_tr += "<td> " + $("#txt_ly_after_" + i + "").val() + "</td>";
                            }
                            else {
                                str_tr += "<td></td>";
                                str_tr += "<td></td>";
                                str_tr += "<td></td>";
                                str_tr += "<td></td>";
                            }
                            if (t > i) {
                                str_tr += "<td> " + mytable_ttcm.rows[i].cells[0].innerHTML + "</td>";
                                str_tr += "<td> " + $("#txt_ttcm_" + i + "").val() + "</td>";
                            } else {
                                str_tr += "<td></td>";
                                str_tr += "<td></td>";
                            }
                            if (i == 0) {
                                str_tr += "<td>长袖/短袖</td>";
                                var pms = $("#pm").text();
                                if ($("#ck_iscd").prop("checked") == true) {
                                    str_tr += "<td>长袖</td>";
                                } else {
                                    str_tr += "<td>短袖</td>";
                                }
                            }
                            if (i == 1) {
                                str_tr += "<td>领型</td>";
                                str_tr += "<td> " + $("#lxmc").text() + "</td>";
                            }
                            if (i == 2) {
                                str_tr += "<td>领插片</td>";
                                str_tr += "<td> " + $("#lcpmc").text() + "</td>";
                            }
                            if (i == 3) {
                                str_tr += "<td>袖口款式</td>";
                                str_tr += "<td> " + $("#xkmc").text() + "</td>";
                            }
                            if (i == 4) {
                                str_tr += "<td>下摆款式</td>";
                                str_tr += "<td> " + $("#xbmc").text() + "</td>";
                            }
                            if (i == 5) {
                                str_tr += "<td>门襟款式</td>";
                                str_tr += "<td> " + $("#qmjmc").text() + "</td>";
                            }
                            if (i == 6) {
                                str_tr += "<td>后背款式</td>";
                                str_tr += "<td> " + $("#hbmc").text() + "</td>";
                            }
                            if (i == 7) {
                                str_tr += "<td>胸袋款式</td>";
                                str_tr += "<td> " + $("#kdmc").text() + "</td>";
                            }
                            if (i == 8) {
                                str_tr += "<td >钮扣</td>";
                                if ($("#sel_nkgy option:selected").text() == "请选择数据")
                                    str_tr += "<td contenteditable='true'> </td>";
                                else
                                    str_tr += "<td contenteditable='true'>" + $("#sel_nkgy option:selected").text() + "</td>";
                            }
                            if (i == 9) {
                                str_tr += "<td >门襟装饰工艺</td>";
                                if ($("#sel_mjgy option:selected").text() == "请选择数据")
                                    str_tr += "<td contenteditable='true'> </td>";
                                else
                                    str_tr += "<td contenteditable='true'>" + $("#sel_mjgy option:selected").text() + "</td>";
                            }
                            if (i == 10) {
                                str_tr += "<td >领子装饰工艺</td>";
                                if ($("#sel_lzgy option:selected").text() == "请选择数据")
                                    str_tr += "<td contenteditable='true'> </td>";
                                else
                                    str_tr += "<td contenteditable='true'>" + $("#sel_lzgy option:selected").text() + "</td>";
                            }
                            if (i == 11) {
                                str_tr += "<td >袖口装饰工艺</td>";
                                if ($("#sel_xkgy option:selected").text() == "请选择数据")
                                    str_tr += "<td contenteditable='true'> </td>";
                                else
                                    str_tr += "<td contenteditable='true'>" + $("#sel_xkgy option:selected").text() + "</td>";
                            }
                            if (i == 12) {
                                str_tr += "<td>绣花位置</td>";
                                str_tr += "<td> " + $("#xhbwmc").text() + "</td>";
                            }
                            if (i == 13) {
                                str_tr += "<td>绣花字体</td>";
                                str_tr += "<td> " + $("#xhztmc").text() + "</td>";
                            }
                            if (i == 14) {
                                str_tr += "<td>绣花颜色</td>";
                                str_tr += "<td> " + $("#xhysmc").text() + "</td>";
                            }
                            if (i == 15) {
                                str_tr += "<td>绣花内容</td>";
                                str_tr += "<td> " + $("#txt_xh_remark").val() + "</td>";
                            }
                            str_tr += "</tr>";
                        }
                        $("#tb_cm").html(str_tr);
                    }
                    //layer.msg(obj.index + '：' + this.innerHTML);
                });
                //监听是否直发，如果是清空地址
                form.on('switch(switchTest)', function (data) {
                    if (data.elem.checked) {
                        $("#txt_address").val('');//清空地址
                    }
                    else {
                        $("#txt_address").val($("#hid_address").val());//清空地址
                    }
                });
                //监听是否加急，如果是加载加急天数和加急费用，把收货日期减加急天
                form.on('switch(switch_jj)', function (data) {
                    if (data.elem.checked) {
                        $("#txt_jjts").val(jjts_ts);
                        $("#txt_jjfy").val(jjfy_fy);
                        $("#jhrq").val(jhrq_cut);
                    } else {
                        $("#txt_jjts").val('');
                        $("#txt_jjfy").val('');
                        $("#jhrq").val(jhrq);
                    }
                });
                //监听长短袖
                form.on('switch(switch_cd)', function (data) {
                    var sel_cm_id = $("select[name='sel_cm']").val();//尺码
                    var hbname = $('#hbmc').text();
                    if (hbname == null || hbname == "" || sel_cm_id == null || sel_cm_id == "") {
                        $("#list_cm").html('');
                        return;
                    }
                    else {
                        $.ajax({
                            type: "post",
                            url: "ashx/list.ashx?type=getcmbysel&cmid=" + sel_cm_id + '&cxordx=' + $("#ck_iscd").prop("checked") + '&hbname=' + hbname,
                            dataType: "json",
                            success: function (data) {
                                var html = '';
                                //如果是自定义尺码，那么手工填写
                                if (sel_cm_id == "13") {
                                    for (var i = 0; i < data.data.length; i++) {
                                        html += "<tr>";
                                        html += "<td><input id='hid_id_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].bwothername + "</td>";
                                        html += "<td><input type='text' onblur='check_zdycm_ckgg_szAndone(" + i + ")' id='txt_ly_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "<td>";
                                        html += "<input type='text' name='fullname' id='txt_ggxz_" + i + "' onblur='check_zdycm_ggxz_szAndone(" + i + ")' lay-verify='required' autocomplete='off' class='layui-input'> ";
                                        html += "</td>";
                                        html += "<td><input type='text' onblur='check_one(this)' id='txt_ly_after_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "</tr>";
                                    }
                                }
                                else {
                                    for (var i = 0; i < data.data.length; i++) {
                                        html += "<tr>";
                                        html += "<td><input id='hid_id_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].bwothername + "</td>";
                                        html += "<td><input readonly='readonly' type='text'  id='txt_ly_" + i + "' value='" + data.data[i].value + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "<td><input id='hid_max_" + i + "' type='hidden' value=" + data.data[i].maxvalue + ">";
                                        html += "<input id='hid_min_" + i + "' type='hidden' value=" + data.data[i].minvalue + ">";
                                        html += "<input type='text' name='fullname' id='txt_ggxz_" + i + "' onblur='check_cm_szAndone(" + i + ")' lay-verify='required' placeholder='" + data.data[i].minvalue + "到" + data.data[i].maxvalue + "' autocomplete='off' class='layui-input'> ";
                                        html += "</td>";
                                        html += "<td><input readonly='readonly'  type='text' value='" + data.data[i].value + "' id='txt_ly_after_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "</tr>";
                                    }
                                }
                                $("#list_cm").html(html);
                            },
                            error: function (data) {
                                layer.error(data);
                            }
                        });
                    }
                });

                //如果没有预收单号隐藏内容
                var ysdh = $("#lbl_ysdh").text();
                if (ysdh == "" || ysdh == null) {
                    $("#allcontent").hide();//选项卡内容
                    $("#lbl_ysdhh").hide();//预收单
                    $("#tjandbc").hide();//提交和保存
                    //绣花颜色、字体、备注隐藏
                    $("#th_xhzt").hide();
                    $("#th_xhys").hide();
                    $("#th_xhbz").hide();
                    $("#td_pic_xhzt").hide();
                    $("#td_pic_xhys").hide();
                    $("#td_pic_xhbz").hide();
                    $("#td_bh_xhzt").hide();
                    $("#td_bh_xhys").hide();
                    $("#td_mc_xhzt").hide();
                    $("#td_mc_xhys").hide();
                }
                else {
                    $("#allcontent").show();//基本信息
                    $("#lbl_ysdhh").show();
                    $("#tjandbc").show();
                }
                var imgurl = "";
                //多图片上传
                upload.render({
                    elem: '#test-upload-more'
                    , url: '../../ashx/uploads_img.ashx'
                    , multiple: true
                    , before: function (obj) {
                        //预读本地文件示例，不支持ie8
                        obj.preview(function (index, file, result) {
                            $('#test-upload-more-list').append('<img src="' + result + '"  alt="image" class="layui-upload-img">')
                        });
                    }
                    , done: function (res) {
                        //上传完毕
                        if (res.code === "100") {
                            layer.msg(res.msg);
                            //$(this.item).prev("div").children("input").val(res.url)
                            var wburl = "http://yj.satchi.com.cn:8085" + res.url2;
                            var imgs = '<img src="' + wburl + '"  alt="image" class="layui-upload-img">';
                            imgurl += imgs;

                            urls += res.url + "|";
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                });
                //加载尺码信息
                $.ajax({
                    type: "post",
                    url: "ashx/list.ashx?type=getcm",
                    dataType: "json",
                    success: function (data) {
                        var html = '';
                        if (data.data.length == 0) {
                            html += "<option value=''>无数据</option>";
                            $("#sel_cm").empty().append(html);
                        } else {
                            html += "<option value=''>请选择数据</option>";
                            for (var i = 0; i < data.data.length; i++) {
                                html += "<option value='" + data.data[i].id + "'>" + data.data[i].cmwm + "</option>"
                            }
                            $("#sel_cm").empty().append(html);
                        }
                        form.render('select');
                    },
                    error: function (data) {
                        layer.error(data);
                    }
                });
                //加载特体信息
                $.ajax({
                    type: "post",
                    url: "ashx/list.ashx?type=getothercm",
                    dataType: "json",
                    success: function (data) {
                        var html = '';
                        for (var i = 0; i < data.data.length; i++) {
                            html += "<tr>";
                            html += "<td><input id='hid_ttid_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].sbname + "";
                            html += "<input id='ttcm_hid_max_" + i + "' type='hidden' value=" + data.data[i].maxvalue + ">";
                            html += "<input id='ttcm_hid_min_" + i + "' type='hidden' value=" + data.data[i].minvalue + "></td>";
                            html += "<td><input type='text' onblur='check_ttcm_szAndone(" + i + ")' id='txt_ttcm_" + i + "' name='fullname' lay-verify='required'  placeholder='" + data.data[i].minvalue + "到" + data.data[i].maxvalue + "' autocomplete='off' class='layui-input'></td>";
                            html += "</tr>";
                        }
                        $("#list_othercm").html(html);
                    },
                    error: function (data) {
                        layer.error(data);
                    }
                });
                //#region 装饰工艺加载
                //加载纽扣工艺信息
                $.ajax({
                    type: "post",
                    url: "ashx/list.ashx?type=getzsgy&gylx=nk",
                    dataType: "json",
                    success: function (data) {
                        var html = '';
                        if (data.data.length == 0) {
                            html += "<option value=''>无数据</option>";
                            $("#sel_nkgy").empty().append(html);
                        } else {
                            html += "<option value=''>请选择数据</option>";
                            for (var i = 0; i < data.data.length; i++) {
                                html += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>"
                            }
                            $("#sel_nkgy").empty().append(html);
                        }
                        form.render('select');
                    },
                    error: function (data) {
                        layer.error(data);
                    }
                });
                //加载门襟装饰工艺信息
                $.ajax({
                    type: "post",
                    url: "ashx/list.ashx?type=getzsgy&gylx=mjzsgy",
                    dataType: "json",
                    success: function (data) {
                        var html = '';
                        if (data.data.length == 0) {
                            html += "<option value=''>无数据</option>";
                            $("#sel_mjgy").empty().append(html);
                        } else {
                            html += "<option value=''>请选择数据</option>";
                            for (var i = 0; i < data.data.length; i++) {
                                html += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>"
                            }
                            $("#sel_mjgy").empty().append(html);
                        }
                        form.render('select');
                    },
                    error: function (data) {
                        layer.error(data);
                    }
                });
                //加载领子装饰工艺信息
                $.ajax({
                    type: "post",
                    url: "ashx/list.ashx?type=getzsgy&gylx=lzzsgy",
                    dataType: "json",
                    success: function (data) {
                        var html = '';
                        if (data.data.length == 0) {
                            html += "<option value=''>无数据</option>";
                            $("#sel_lzgy").empty().append(html);
                        } else {
                            html += "<option value=''>请选择数据</option>";
                            for (var i = 0; i < data.data.length; i++) {
                                html += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>"
                            }
                            $("#sel_lzgy").empty().append(html);
                        }
                        form.render('select');
                    },
                    error: function (data) {
                        layer.error(data);
                    }
                });
                //加载袖口装饰工艺信息
                $.ajax({
                    type: "post",
                    url: "ashx/list.ashx?type=getzsgy&gylx=xkzsgy",
                    dataType: "json",
                    success: function (data) {
                        var html = '';
                        if (data.data.length == 0) {
                            html += "<option value=''>无数据</option>";
                            $("#sel_xkgy").empty().append(html);
                        } else {
                            html += "<option value=''>请选择数据</option>";
                            for (var i = 0; i < data.data.length; i++) {
                                html += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>"
                            }
                            $("#sel_xkgy").empty().append(html);
                        }
                        form.render('select');
                    },
                    error: function (data) {
                        layer.error(data);
                    }
                });
                //#endregion
                //选择尺码带出部位信息
                form.on('select(sel_cm)', function (data) {
                    var sel_cm_id = data.value;
                    var hbname = $('#hbmc').text();
                    if (hbname == null || hbname == "") {
                        //layer.msg('请选择后背图案', { icon: 7 });
                        $("#list_cm").html('');
                        return;
                    }
                    else {
                        $.ajax({
                            type: "post",
                            url: "ashx/list.ashx?type=getcmbysel&cmid=" + sel_cm_id + '&cxordx=' + $("#ck_iscd").prop("checked") + '&hbname=' + hbname,
                            dataType: "json",
                            success: function (data) {
                                var html = '';
                                //如果是自定义尺码，那么手工填写
                                if (sel_cm_id == "13") {
                                    for (var i = 0; i < data.data.length; i++) {
                                        html += "<tr>";
                                        html += "<td><input id='hid_id_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].bwothername + "</td>";
                                        html += "<td><input type='text' onblur='check_zdycm_ckgg_szAndone(" + i + ")' id='txt_ly_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "<td>";
                                        html += "<input type='text' name='fullname' id='txt_ggxz_" + i + "' onblur='check_zdycm_ggxz_szAndone(" + i + ")' lay-verify='required' autocomplete='off' class='layui-input'> ";
                                        html += "</td>";
                                        html += "<td><input type='text' onblur='check_one(this)' id='txt_ly_after_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "</tr>";
                                    }
                                }
                                else {
                                    for (var i = 0; i < data.data.length; i++) {
                                        html += "<tr>";
                                        html += "<td><input id='hid_id_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].bwothername + "</td>";
                                        html += "<td><input readonly='readonly' type='text'  id='txt_ly_" + i + "' value='" + data.data[i].value + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "<td><input id='hid_max_" + i + "' type='hidden' value=" + data.data[i].maxvalue + ">";
                                        html += "<input id='hid_min_" + i + "' type='hidden' value=" + data.data[i].minvalue + ">";
                                        html += "<input type='text' name='fullname' id='txt_ggxz_" + i + "' onblur='check_cm_szAndone(" + i + ")' lay-verify='required' placeholder='" + data.data[i].minvalue + "到" + data.data[i].maxvalue + "' autocomplete='off' class='layui-input'> ";
                                        html += "</td>";
                                        html += "<td><input readonly='readonly'  type='text' value='" + data.data[i].value + "' id='txt_ly_after_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                        html += "</tr>";
                                    }
                                }
                                $("#list_cm").html(html);
                            },
                            error: function (data) {
                                layer.error(data);
                            }
                        });
                    }
                });
                //根据工厂面料号带出面料编码、面料品牌
                $("#txt_gcmlh").on("input", function (e) {
                    var values = e.delegateTarget.value;
                    //获取input输入的值
                    $.ajax({
                        type: "post",
                        url: "ashx/list.ashx?type=getmlbm_bygcmlh",
                        dataType: "json",
                        data: { gcmlh: values },
                        success: function (data) {
                            if (data.code == "0") {
                                $("#mlpp").text(data.mlpp);
                                $("#mlbm").text(data.mlbm);
                            } else {
                                $("#mlpp").text('');
                                $("#mlbm").text('');
                            }

                        },
                        error: function (data) {
                            //layer.error(data);
                        }
                    });
                });
                //打开预收单
                $('#ysd').on('click', function () {
                    var index = layer.open({
                        type: 2,
                        area: ['90%', '95%'],
                        shade: false,
                        maxmin: true,
                        title: '选择预收单',
                        btn: ["确定", '关闭'],
                        content: 'select_ysd.html',
                        yes: function (index, layero) {
                            var obj = $(layero).find("iframe")[0].contentWindow;
                            $(layero).find("iframe")[0].contentWindow.$('#saveBtn').click();//执行子页面的按钮点击事件
                            var mJson = obj.$('#uidsub').val();//获取子页面绑定的值
                            if (mJson != "") {
                                $("#allcontent").show();//基本信息
                                $("#lbl_ysdhh").show();
                                $("#tjandbc").show();
                                var _mJson = $.parseJSON(mJson);//转成Json对象
                                $("#lbl_ysdh").text(_mJson[0].docno);//重新赋值
                                $("#txt_mendian").val(_mJson[0].dcname);
                                $("#hid_storeid").val(_mJson[0].storeid);
                                $("#txt_storecode").val(_mJson[0].dccode);
                                $("#txt_address").val(_mJson[0].address);
                                $("#hid_address").val(_mJson[0].address);
                                $("#kh").text(_mJson[0].name);
                                $("#pm").text(_mJson[0].xiaolei);
                                $("#hid_xiaolei").val(_mJson[0].xiaolei);
                                var xiaolei = _mJson[0].xiaolei;
                                //长短袖
                                if (xiaolei.indexOf("长") != -1) {
                                    $("#ck_iscd").attr("checked", "checked");
                                    $("#ck_iscd").attr("value", '长袖');
                                }
                                else if (xiaolei.indexOf("短") != -1) {
                                    $("#ck_iscd").removeAttr("checked");
                                    var x = document.getElementsByClassName("layui-unselect layui-form-switch layui-form-onswitch");
                                    var d = document.getElementsByTagName('em')[0];
                                    d.firstChild.nodeValue = '短袖';
                                }
                                else {
                                    $("#ck_iscd").attr("checked", "checked");
                                    $("#ck_iscd").attr("value", '长袖');
                                }
                                form.render('checkbox');

                                //$("#cm").text(_mJson[0].value2);
                                $("#jg").text(_mJson[0].pricelist);
                                $("#txt_sl").val(_mJson[0].qty);
                                $("#hid_sl").val(_mJson[0].qty);
                                $("#mlpp").text(_mJson[0].mlpp);
                                $("#mlbm").text(_mJson[0].mlbm);
                                $("#txt_gcmlh").val(_mJson[0].gcmlbm);
                            }
                        },
                        cancel: function (index, layero) {
                            // 取消的操作
                        },
                        end: function () { }
                    });
                });


                $('#component-tabs .site-demo-active').on('click', function () {
                    var othis = $(this), type = othis.data('type');
                    active[type] ? active[type].call(this, othis) : '';
                });

                /* Hash地址的定位 */
                var layid = router.hash.replace(/^#layid=/, '');
                layid && element.tabChange('component-tabs-hash', layid);

                element.on('tab(component-tabs-hash)', function (elem) {
                    location.hash = '/' + layui.router().path.join('/') + '#layid=' + $(this).attr('lay-id');
                });
            });

            //尺码根据公差减
            function jian(bwid) {
                var txt_ly_after_ = parseFloat($("#txt_ly_after_" + bwid + "").val());//成衣尺寸
                var btn_jian = parseFloat($("#jian_" + bwid + "").val());//公差
                var txt_min = parseFloat($("#hid_min_" + bwid + "").val());//最小值
                var jsz = parseFloat(txt_ly_after_ - btn_jian).toFixed(1);//成衣尺寸减公差
                if (jsz < txt_min) {
                    layer.msg("小于最小值" + txt_min + ",不允许!");
                    return;
                }
                $("#txt_ly_after_" + bwid + "").val(jsz);
            }
            //尺码根据公差加
            function jia(bwid) {
                var txt_ly_after_ = parseFloat($("#txt_ly_after_" + bwid + "").val()); //成衣尺寸
                var btn_jia = parseFloat($("#jia_" + bwid + "").val());//公差
                var txt_max = parseFloat($("#hid_max_" + bwid + "").val());//最大值
                var jsz = parseFloat(txt_ly_after_ + btn_jia).toFixed(1);//成衣尺寸加公差
                if (jsz > txt_max) {
                    layer.msg("大于最大值" + txt_max + ",不允许!");
                    return;
                }
                $("#txt_ly_after_" + bwid + "").val(jsz);
            }

            //打开选择领型等
            function select_pic(type) {
                var index = layer.open({
                    type: 2,
                    area: ['90%', '95%'],
                    shade: true,
                    maxmin: true,
                    title: '选择图片',
                    btn: ["确定", '关闭', "清除"],
                    content: 'select_pic.html?type=' + type + '&cxordx=' + $("#ck_iscd").prop("checked"),
                    yes: function (index, layero) {
                        var obj = $(layero).find("iframe")[0].contentWindow;
                        $(layero).find("iframe")[0].contentWindow.$('#saveBtn').click();//执行子页面的按钮点击事件
                        var mJson = obj.$('#uidsub').val();//获取子页面绑定的值
                        if (mJson != "") {
                            // 在每个空格字符处进行分解。
                            var geturls = mJson.split(",");
                            if (type == "lx") {
                                $("#lxid").val(geturls[0]);
                                $("#lxmc").text(geturls[1]);
                                $("#lxpic").attr("src", geturls[2]);
                                $("#lxbh").text(geturls[3]);
                            }
                            if (type == "xk") {
                                $("#xkid").val(geturls[0]);
                                $("#xkmc").text(geturls[1]);
                                $("#xkpic").attr("src", geturls[2]);
                                $("#xkbh").text(geturls[3]);
                            }
                            if (type == "qmj") {
                                $("#qmjid").val(geturls[0]);
                                $("#qmjmc").text(geturls[1]);
                                $("#qmjpic").attr("src", geturls[2]);
                                $("#qmjbh").text(geturls[3]);
                            }
                            if (type == "xb") {
                                $("#xbid").val(geturls[0]);
                                $("#xbmc").text(geturls[1]);
                                $("#xbpic").attr("src", geturls[2]);
                                $("#xbbh").text(geturls[3]);
                            }
                            if (type == "hb") {
                                $("#hbid").val(geturls[0]);
                                $("#hbmc").text(geturls[1]);
                                $("#hbpic").attr("src", geturls[2]);
                                $("#hbbh").text(geturls[3]);

                                //选择后背后带出尺码信息
                                var sel_cm_id = $("select[name='sel_cm']").val();//尺码
                                var hbname = $('#hbmc').text();
                                if (sel_cm_id == null || sel_cm_id == "") {
                                    layer.msg('请选择尺码', { icon: 7 });
                                    $("#list_cm").html('');
                                    return;
                                }
                                else {
                                    $.ajax({
                                        type: "post",
                                        url: "ashx/list.ashx?type=getcmbysel&cmid=" + sel_cm_id + '&cxordx=' + $("#ck_iscd").prop("checked") + '&hbname=' + hbname,
                                        dataType: "json",
                                        success: function (data) {
                                            var html = '';
                                            //如果是自定义尺码，那么手工填写
                                            if (sel_cm_id == "13") {
                                                for (var i = 0; i < data.data.length; i++) {
                                                    html += "<tr>";
                                                    html += "<td><input id='hid_id_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].bwothername + "</td>";
                                                    html += "<td><input type='text' onblur='check_zdycm_ckgg_szAndone(" + i + ")' id='txt_ly_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                                    html += "<td>";
                                                    html += "<input type='text' name='fullname' id='txt_ggxz_" + i + "' onblur='check_zdycm_ggxz_szAndone(" + i + ")' lay-verify='required' autocomplete='off' class='layui-input'> ";
                                                    html += "</td>";
                                                    html += "<td><input type='text' onblur='check_one(this)' id='txt_ly_after_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                                    html += "</tr>";
                                                }
                                            } else {
                                                for (var i = 0; i < data.data.length; i++) {
                                                    html += "<tr>";
                                                    html += "<td><input id='hid_id_" + i + "' type='hidden' value=" + data.data[i].id + ">" + data.data[i].bwothername + "</td>";
                                                    html += "<td><input readonly='readonly' type='text'  id='txt_ly_" + i + "' value='" + data.data[i].value + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                                    html += "<td><input id='hid_max_" + i + "' type='hidden' value=" + data.data[i].maxvalue + ">";
                                                    html += "<input id='hid_min_" + i + "' type='hidden' value=" + data.data[i].minvalue + ">";
                                                    html += "<input type='text' name='fullname' id='txt_ggxz_" + i + "' onblur='check_cm_szAndone(" + i + ")' lay-verify='required' placeholder='" + data.data[i].minvalue + "到" + data.data[i].maxvalue + "' autocomplete='off' class='layui-input'> ";
                                                    html += "</td>";
                                                    html += "<td><input readonly='readonly'  type='text' value='" + data.data[i].value + "' id='txt_ly_after_" + i + "' name='fullname' lay-verify='required' placeholder='' autocomplete='off' class='layui-input'></td>";
                                                    html += "</tr>";
                                                }
                                            }
                                            $("#list_cm").html(html);
                                        },
                                        error: function (data) {
                                            layer.error(data);
                                        }
                                    });
                                }
                            }
                            if (type == "kd") {
                                $("#kdid").val(geturls[0]);
                                $("#kdmc").text(geturls[1]);
                                $("#kdpic").attr("src", geturls[2]);
                                $("#kdbh").text(geturls[3]);
                            }
                            if (type == "lcp") {
                                $("#lcpid").val(geturls[0]);
                                $("#lcpmc").text(geturls[1]);
                                $("#lcppic").attr("src", geturls[2]);
                                $("#lcpbh").text(geturls[3]);
                            }
                            if (type == "xhbw") {
                                $("#xhbwid").val(geturls[0]);
                                $("#xhbwmc").text(geturls[1]);
                                $("#xhbwpic").attr("src", geturls[2]);
                                $("#xhbwbh").text(geturls[3]);
                                //当打开绣花部位时显示字体、颜色、备注
                                $("#th_xhzt").show();
                                $("#th_xhys").show();
                                $("#th_xhbz").show();
                                $("#td_pic_xhzt").show();
                                $("#td_pic_xhys").show();
                                $("#td_pic_xhbz").show();
                                $("#td_bh_xhzt").show();
                                $("#td_bh_xhys").show();
                                $("#td_mc_xhzt").show();
                                $("#td_mc_xhys").show();
                            }
                            if (type == "xhzt") {
                                $("#xhztid").val(geturls[0]);
                                $("#xhztmc").text(geturls[1]);
                                $("#xhztpic").attr("src", geturls[2]);
                                $("#xhztbh").text(geturls[3]);
                            }
                            if (type == "xhys") {
                                $("#xhysid").val(geturls[0]);
                                $("#xhysmc").text(geturls[1]);
                                $("#xhyspic").attr("src", geturls[2]);
                                $("#xhysbh").text(geturls[3]);
                            }
                        }
                    },
                    cancel: function (index, layero) {

                    },
                    btn3: function (index, layero) {
                        if (type == "lx") {
                            $("#lxid").val("");
                            $("#lxmc").text("");
                            $("#lxpic").attr("src", "../../layuiadmin/style/res/template/lx_icon.png");
                            $("#lxbh").text("");
                        }
                        if (type == "xk") {
                            $("#xkid").val("");
                            $("#xkmc").text("");
                            $("#xkpic").attr("src", "../../layuiadmin/style/res/template/xk_icon.png");
                            $("#xkbh").text("");
                        }
                        if (type == "qmj") {
                            $("#qmjid").val("");
                            $("#qmjmc").text("");
                            $("#qmjpic").attr("src", "../../layuiadmin/style/res/template/qmj_icon.png");
                            $("#qmjbh").text("");
                        }
                        if (type == "xb") {
                            $("#xbid").val("");
                            $("#xbmc").text("");
                            $("#xbpic").attr("src", "../../layuiadmin/style/res/template/xb_icon.png");
                            $("#xbbh").text("");
                        }
                        if (type == "hb") {
                            $("#hbid").val("");
                            $("#hbmc").text("");
                            $("#hbpic").attr("src", "../../layuiadmin/style/res/template/hb_icon.png");
                            $("#hbbh").text("");
                        }
                        if (type == "kd") {
                            $("#kdid").val("");
                            $("#kdmc").text("");
                            $("#kdpic").attr("src", "../../layuiadmin/style/res/template/kd_icon.png");
                            $("#kdbh").text("");
                        }
                        if (type == "lcp") {
                            $("#lcpid").val("");
                            $("#lcpmc").text("");
                            $("#lcppic").attr("src", "../../layuiadmin/style/res/template/lcp_icon.png");
                            $("#lcpbh").text("");
                        }
                        if (type == "xhbw") {
                            $("#xhbwid").val("");
                            $("#xhbwmc").text("");
                            $("#xhbwpic").attr("src", "../../layuiadmin/style/res/template/xhbw_icon.png");
                            $("#xhbwbh").text("");

                            //当清除绣花部位时隐藏字体、颜色、备注
                            $("#th_xhzt").hide();
                            $("#th_xhys").hide();
                            $("#th_xhbz").hide();
                            $("#td_pic_xhzt").hide();
                            $("#td_pic_xhys").hide();
                            $("#td_pic_xhbz").hide();
                            $("#td_bh_xhzt").hide();
                            $("#td_bh_xhys").hide();
                            $("#td_mc_xhzt").hide();
                            $("#td_mc_xhys").hide();

                            $("#xhztid").val("");
                            $("#xhztmc").text("");
                            $("#xhztpic").attr("src", "../../layuiadmin/style/res/template/xhzt_icon.png");
                            $("#xhztbh").text("");
                            $("#xhysid").val("");
                            $("#xhysmc").text("");
                            $("#xhyspic").attr("src", "../../layuiadmin/style/res/template/xhys_icon.png");
                            $("#xhysbh").text("");
                            $("#txt_xh_remark").val("");//绣花其他要求
                        }
                        if (type == "xhzt") {
                            $("#xhztid").val("");
                            $("#xhztmc").text("");
                            $("#xhztpic").attr("src", "../../layuiadmin/style/res/template/xhzt_icon.png");
                            $("#xhztbh").text("");
                        }
                        if (type == "xhys") {
                            $("#xhysid").val("");
                            $("#xhysmc").text("");
                            $("#xhyspic").attr("src", "../../layuiadmin/style/res/template/xhys_icon.png");
                            $("#xhysbh").text("");
                        }
                    },
                    end: function () { }
                });
                //layer.full(index);
            }
        </script>
</body>
</html>

